package org.ioc.com.mybatis_test2.mapper;

import org.apache.ibatis.annotations.*;
import org.ioc.com.mybatis_test2.model.UserInfo;

import java.util.List;

@Mapper
public interface UserInfoMapper {
    @Select("select * from userinfo")
    List<UserInfo> getUserAll();

    @Insert("insert into userinfo(username,password,age,gender) values (#{username},#{password},#{age},#{gender})")
    Integer insert(UserInfo userInfo);

    @Delete("delete from userinfo where id=#{id}")
    Integer delete(Integer id);

    @Update("update userinfo set age=#{age} where id=#{id}")
    Integer update(Integer age,Integer id);

    @Select("select id,username,age,password,gender,phone,delete_flag as deleteFLag,create_time as createTime,update_time as updateTime from userinfo")
    List<UserInfo> getUserAll1();


    @Results(id = "resultMap",value = {
            @Result(column = "delete_flag",property = "deleteFLag"),
            @Result(column = "create_time",property = "createTime"),
            @Result(column = "update_time",property = "updateTime")
    })
    @Select("select * from userinfo")
    List<UserInfo> getUserAll2();

    @ResultMap("resultMap")
    @Select("select * from userinfo")
    List<UserInfo> getUserAll3();
}
